package com.htzz.collection.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class ThreadConfig {

    @Value("${thread.corePoolSize}")
    private int corePoolSize;
    @Value("${thread.maximumPoolSize}")
    private int maximumPoolSize;
    @Value("${thread.keepLive}")
    private long keepLive;

    @Bean
    public ThreadPoolExecutor threadPoolExecutor(){
        return new ThreadPoolExecutor(corePoolSize,maximumPoolSize,keepLive, TimeUnit.MILLISECONDS,new LinkedBlockingQueue<>());
    }

}
